//---------------------------------------------------------------------------

#ifndef h_stageH
#define h_stageH
//---------------------------------------------------------------------------
#include "h_xml.h"

class HStageIcon;

class HStage
{
public :

   __fastcall HStage(void);
   virtual __fastcall ~HStage(void);
   virtual HStage * __fastcall Clone(void) = 0;
   virtual UTF8String __fastcall GetType(void) = 0;
   virtual bool __fastcall EditProperty(void) = 0;
   virtual void __fastcall SaveProperty(h_xml::HXmlTree *Node) = 0;
   virtual void __fastcall LoadProperty(h_xml::HXmlTree *Node, bool XmlPropertyFlag) = 0;
   virtual UTF8String __fastcall GetCaption(void) = 0;
   virtual bool __fastcall GetPartFlag(void) = 0;
   virtual bool __fastcall GetExternFlag(void) = 0;
   virtual bool __fastcall GetLoopFlag(void) = 0;
   virtual int __fastcall GetIconType(void) = 0;
   virtual int __fastcall GetIconEnlarge(void) = 0;
   virtual void __fastcall GetIconSize(int &Width, int &Height) = 0;
   virtual UTF8String __fastcall GetHint()
   {
      return "";
   }
   virtual void __fastcall GetJobListInfo(const UTF8String &GroupId,
      HJobListInfo &Info)
   {
      Info = HJobListInfo();
   }

   UTF8String __fastcall GetGroupId(void);
   void __fastcall SetGroupId(const UTF8String &GroupId);
   UTF8String __fastcall GetName(void);
   void __fastcall SetName(const UTF8String &Name);
   HStageIcon * __fastcall GetIcon(void);
   void __fastcall CreateIcon(TWinControl * Parent);
   void __fastcall Move(int x, int y);
   void __fastcall RefreshCaption(void);
   bool __fastcall IsValidJobName(const string &Name);
   void __fastcall AdjustLabel();
   static int StringToAlarmTimeType(const UTF8String &Str);
   static UTF8String AlarmTimeTypeToString(int Type);

private :

   UTF8String FGroupId;
   UTF8String FName;
   HStageIcon *FIcon;
   TLabel *FLabel;
};

class HStageJob : public HStage
{
public :

   __fastcall HStageJob(void);
   virtual HStage * __fastcall Clone(void);
   virtual UTF8String __fastcall GetType(void);
   virtual int __fastcall GetIconEnlarge(void);
   virtual bool __fastcall EditProperty(void);
   virtual void __fastcall SaveProperty(h_xml::HXmlTree *Node);
   virtual void __fastcall LoadProperty(h_xml::HXmlTree *Node, bool XmlPropertyFlag);
   virtual UTF8String __fastcall GetCaption(void);
   virtual bool __fastcall GetPartFlag(void);
   virtual bool __fastcall GetExternFlag(void);
   virtual bool __fastcall GetLoopFlag(void);
   virtual int __fastcall GetIconType(void);
   virtual void __fastcall GetIconSize(int &Width, int &Height);
   virtual UTF8String __fastcall GetHint();
   virtual void __fastcall GetJobListInfo(const UTF8String &GroupId,
      HJobListInfo &Info);

   struct HInfo
   {
      UTF8String Name;
      UTF8String Command;
      UTF8String RestoreCommand;
      UTF8String Description;
      UTF8String SpecialDate;
      UTF8String BusinessType;
      bool CondNot;
      UTF8String ConditionFile;
      UTF8String AdditionalLog;
      int AlarmTimeType;
      UTF8String AlarmTime;
      UTF8String JobTrigger;
      UTF8String PartitionFile;
      bool Exclusive;
      int ParallelJobNumber;
      int Priority;
      UTF8String AutoRerun;
      int Enlarge;
      bool Anchor;
      UTF8String Tag;
      UTF8String RunningGroup;
      vector<string> ResourceList;
      vector<string> ExternJobList;
      UTF8String LoopStartTime;
      UTF8String LoopEndTime;
      UTF8String LoopInterval;
      UTF8String LoopCount;
      UTF8String LoopConditionVariable;
      __fastcall HInfo()
      {
         CondNot = false;
         AlarmTimeType = 0;
         Exclusive = false;
         ParallelJobNumber = 0;
         Priority = 0;
         Enlarge = 0;
         Anchor = false;
      }
   };

   void __fastcall GetInfo(HInfo &Info);
   bool __fastcall SetInfo(const HInfo &Info,
      UTF8String &ErrorString);

private :

   HInfo FInfo;
};

class HStageConnector : public HStage
{
public :

   virtual HStage * __fastcall Clone(void);
   virtual UTF8String __fastcall GetType(void);
   virtual int __fastcall GetIconEnlarge(void);
   virtual bool __fastcall EditProperty(void);
   virtual void __fastcall SaveProperty(h_xml::HXmlTree *Node);
   virtual void __fastcall LoadProperty(h_xml::HXmlTree *Node, bool XmlPropertyFlag);
   virtual UTF8String __fastcall GetCaption(void);
   virtual bool __fastcall GetPartFlag(void);
   virtual bool __fastcall GetExternFlag(void);
   virtual bool __fastcall GetLoopFlag(void);
   virtual int __fastcall GetIconType(void);
   virtual void __fastcall GetIconSize(int &Width, int &Height);
   virtual UTF8String __fastcall GetHint();

   struct HInfo
   {
      bool HideArrow;
      HInfo() : HideArrow(false)
      {}
   };

   void __fastcall GetInfo(HInfo &Info);
   bool __fastcall SetInfo(const HInfo &Info,
      UTF8String &ErrorString);

private :

   HInfo FInfo;
};

class HStageExternJob : public HStage
{
public :

   virtual HStage * __fastcall Clone(void);
   virtual UTF8String __fastcall GetType(void);
   virtual int __fastcall GetIconEnlarge(void);
   virtual bool __fastcall EditProperty(void);
   virtual void __fastcall SaveProperty(h_xml::HXmlTree *Node);
   virtual void __fastcall LoadProperty(h_xml::HXmlTree *Node, bool XmlPropertyFlag);
   virtual UTF8String __fastcall GetCaption(void);
   virtual bool __fastcall GetPartFlag(void);
   virtual bool __fastcall GetExternFlag(void);
   virtual bool __fastcall GetLoopFlag(void);
   virtual int __fastcall GetIconType(void);
   virtual void __fastcall GetIconSize(int &Width, int &Height);
   virtual UTF8String __fastcall GetHint();

   struct HInfo
   {
      UTF8String ExternGroup;
      UTF8String ExternJob;
      UTF8String Description;
      int Enlarge;
      __fastcall HInfo()
      {
         Enlarge = 0;
      }
   };

   void __fastcall GetInfo(HInfo &Info);
   bool __fastcall SetInfo(const HInfo &Info,
      UTF8String &ErrorString);

private :

   HInfo FInfo;
};

class HStageEventFire : public HStage
{
public :

   virtual HStage * __fastcall Clone(void);
   virtual UTF8String __fastcall GetType(void);
   virtual int __fastcall GetIconEnlarge(void);
   virtual bool __fastcall EditProperty(void);
   virtual void __fastcall SaveProperty(h_xml::HXmlTree *Node);
   virtual void __fastcall LoadProperty(h_xml::HXmlTree *Node, bool XmlPropertyFlag);
   virtual UTF8String __fastcall GetCaption(void);
   virtual bool __fastcall GetPartFlag(void);
   virtual bool __fastcall GetExternFlag(void);
   virtual bool __fastcall GetLoopFlag(void);
   virtual int __fastcall GetIconType(void);
   virtual void __fastcall GetIconSize(int &Width, int &Height);
   virtual UTF8String __fastcall GetHint();
   virtual void __fastcall GetJobListInfo(const UTF8String &GroupId,
      HJobListInfo &Info);

   struct HInfo
   {
      UTF8String Name;
      UTF8String HostName;
      UTF8String Event;
      UTF8String Description;
      UTF8String SpecialDate;
      bool CondNot;
      UTF8String ConditionFile;
      UTF8String JobTrigger;
      int Priority;
      UTF8String AutoRerun;
      UTF8String Tag;
      vector<string> ExternJobList;
      __fastcall HInfo()
      {
         CondNot = false;
         Priority = 0;
      }
   };

   void __fastcall GetInfo(HInfo &Info);
   bool __fastcall SetInfo(const HInfo &Info,
      UTF8String &ErrorString);

private :

   HInfo FInfo;
};

class HStageEventWait : public HStage
{
public :

   virtual HStage * __fastcall Clone(void);
   virtual UTF8String __fastcall GetType(void);
   virtual int __fastcall GetIconEnlarge(void);
   virtual bool __fastcall EditProperty(void);
   virtual void __fastcall SaveProperty(h_xml::HXmlTree *Node);
   virtual void __fastcall LoadProperty(h_xml::HXmlTree *Node, bool XmlPropertyFlag);
   virtual UTF8String __fastcall GetCaption(void);
   virtual bool __fastcall GetPartFlag(void);
   virtual bool __fastcall GetExternFlag(void);
   virtual bool __fastcall GetLoopFlag(void);
   virtual int __fastcall GetIconType(void);
   virtual void __fastcall GetIconSize(int &Width, int &Height);
   virtual UTF8String __fastcall GetHint();
   virtual void __fastcall GetJobListInfo(const UTF8String &GroupId,
      HJobListInfo &Info);

   struct HInfo
   {
      UTF8String Name;
      UTF8String Event;
      UTF8String WaitForFile;
      UTF8String WaitForTime;
      UTF8String WaitForCommand;
      bool WaitForOperator;
      UTF8String Description;
      UTF8String SpecialDate;
      bool CondNot;
      UTF8String ConditionFile;
      UTF8String JobTrigger;
      int Priority;
      UTF8String AutoRerun;
      UTF8String Tag;
      vector<string> ExternJobList;
      __fastcall HInfo()
      {
         WaitForOperator = false;
         CondNot = false;
         Priority = 0;
      }
   };

   void __fastcall GetInfo(HInfo &Info);
   bool __fastcall SetInfo(const HInfo &Info,
      UTF8String &ErrorString);

private :

   HInfo FInfo;
};

class HStageGroup : public HStage
{
public :

   virtual HStage * __fastcall Clone(void);
   virtual UTF8String __fastcall GetType(void);
   virtual int __fastcall GetIconEnlarge(void);
   virtual bool __fastcall EditProperty(void);
   virtual void __fastcall SaveProperty(h_xml::HXmlTree *Node);
   virtual void __fastcall LoadProperty(h_xml::HXmlTree *Node, bool XmlPropertyFlag);
   virtual UTF8String __fastcall GetCaption(void);
   virtual bool __fastcall GetPartFlag(void);
   virtual bool __fastcall GetExternFlag(void);
   virtual bool __fastcall GetLoopFlag(void);
   virtual int __fastcall GetIconType(void);
   virtual void __fastcall GetIconSize(int &Width, int &Height);
   virtual UTF8String __fastcall GetHint();
   virtual void __fastcall GetJobListInfo(const UTF8String &GroupId,
      HJobListInfo &Info);

   struct HInfo
   {
      UTF8String Name;
      UTF8String Group;
      UTF8String Description;
      UTF8String SpecialDate;
      UTF8String BusinessType;
      bool CondNot;
      UTF8String ConditionFile;
      int ParallelJobNumber;
      int Priority;
      UTF8String AutoRerun;
      int Enlarge;
      UTF8String Tag;
      UTF8String RunningGroup;
      vector<string> ExternJobList;
      __fastcall HInfo()
      {
         CondNot = false;
         ParallelJobNumber = 0;
         Priority = 0;
         Enlarge = 0;
      }
   };

   void __fastcall GetInfo(HInfo &Info);
   bool __fastcall SetInfo(const HInfo &Info,
      UTF8String &ErrorString);

private :

   HInfo FInfo;
};

class HStageTime : public HStage
{
public :

   virtual HStage * __fastcall Clone(void);
   virtual UTF8String __fastcall GetType(void);
   virtual int __fastcall GetIconEnlarge(void);
   virtual bool __fastcall EditProperty(void);
   virtual void __fastcall SaveProperty(h_xml::HXmlTree *Node);
   virtual void __fastcall LoadProperty(h_xml::HXmlTree *Node, bool XmlPropertyFlag);
   virtual UTF8String __fastcall GetCaption(void);
   virtual bool __fastcall GetPartFlag(void);
   virtual bool __fastcall GetExternFlag(void);
   virtual bool __fastcall GetLoopFlag(void);
   virtual int __fastcall GetIconType(void);
   virtual void __fastcall GetIconSize(int &Width, int &Height);
   virtual UTF8String __fastcall GetHint();
   virtual void __fastcall GetJobListInfo(const UTF8String &GroupId,
      HJobListInfo &Info);

   struct HInfo
   {
      UTF8String Name;
      UTF8String Time;
      UTF8String Description;
      UTF8String SpecialDate;
      bool CondNot;
      UTF8String ConditionFile;
      UTF8String Tag;
      vector<string> ExternJobList;
      __fastcall HInfo()
      {
         CondNot = false;
         Time = "23:00";
      }
   };

   void __fastcall GetInfo(HInfo &Info);
   bool __fastcall SetInfo(const HInfo &Info,
      UTF8String &ErrorString);

private :

   HInfo FInfo;
};

class HStageBatch : public HStage
{
public :

   virtual HStage * __fastcall Clone(void);
   virtual UTF8String __fastcall GetType(void);
   virtual int __fastcall GetIconEnlarge(void);
   virtual bool __fastcall EditProperty(void);
   virtual void __fastcall SaveProperty(h_xml::HXmlTree *Node);
   virtual void __fastcall LoadProperty(h_xml::HXmlTree *Node, bool XmlPropertyFlag);
   virtual UTF8String __fastcall GetCaption(void);
   virtual bool __fastcall GetPartFlag(void);
   virtual bool __fastcall GetExternFlag(void);
   virtual bool __fastcall GetLoopFlag(void);
   virtual int __fastcall GetIconType(void);
   virtual void __fastcall GetIconSize(int &Width, int &Height);
   virtual UTF8String __fastcall GetHint();
   virtual void __fastcall GetJobListInfo(const UTF8String &GroupId,
      HJobListInfo &Info);

   struct HInfo
   {
      UTF8String Name;
      UTF8String Caption;
      UTF8String HostName;
      UTF8String Batch;
      bool SendDate;
      UTF8String DateVarName;
      UTF8String Description;
      UTF8String SpecialDate;
      bool CondNot;
      UTF8String ConditionFile;
      int AlarmTimeType;
      UTF8String AlarmTime;
      int Enlarge;
      UTF8String Tag;
      vector<string> ExternJobList;
      __fastcall HInfo()
      {
         SendDate = true;
         CondNot = false;
         AlarmTimeType = 0;
         Enlarge = 0;
      }
   };

   void __fastcall GetInfo(HInfo &Info);
   bool __fastcall SetInfo(const HInfo &Info, UTF8String &ErrorString);

   void __fastcall SaveProperty_aux(h_xml::HXmlTree *Node);
   void __fastcall LoadProperty_aux(h_xml::HXmlTree *Node, bool XmlPropertyFlag);

private :

   HInfo FInfo;
};

#endif
